package com.example.manager.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.manager.entity.StudentSubScore;
import com.example.manager.service.StudentSubScoreService;

@RestController
public class StudentSubScoreController {
	
	@Autowired
	private StudentSubScoreService service;
	
	@GetMapping("studentSubScore")
	private List<StudentSubScore> getAll(){
		return service.findAll();
	}
	
	@GetMapping("studentSubScoreByCSid/{id}")
	private List<StudentSubScore> getByCSid(@PathVariable Integer id) {
		return service.getByCourseSelection(id);
	}
	
	@GetMapping("studentSubScoreBySCid/{id}")
	private List<StudentSubScore> getBySCid(@PathVariable Integer id) {
		return service.getByScoreComposition(id);
	}
	
	@PostMapping("studentSubScore")
	private String postStuSubScore(Double subScore, Integer courseSelectionId, Integer scoreCompositionId) {
		return service.postStudentSubScore(subScore, courseSelectionId, scoreCompositionId);
	}
	
	/*@PostMapping("studentSubScore")
	private String postStuSubScore(List<StudentSubScore> scores) {
		return service.postStudentSubScore(scores);
	}*/
	
	/*@PutMapping("studentSubScore/{id}")
	private String putStuSubScore(Double subScore, Integer courseSelectionId, Integer scoreCompositionId) {
		return service.putStuSubScore(subScore, courseSelectionId, scoreCompositionId);
	}*/
	
	@PutMapping("studentSubScore/{id}")
	private String putStuSubScore(StudentSubScore ss, @PathVariable Integer id) {
		ss.setId(id);
		return service.putStuSubScore(ss);
	}
	
	@DeleteMapping("studentSubScore/{id}")
	private String delStuSubScore(@PathVariable Integer id) {
		return service.delStuSubScore(id);
	}
	
}
